#include <stdio.h>

int main(int argc, char **argv)
{
    // stdin:键盘
    // stdout stderr：终端文件
#if 0
    char buffer[1024] = {0};
    fgets(buffer, 1024, stdin);
    fputs(buffer, stdout);

    fputs("open file error!", stdout);
#endif
    FILE *fp = fopen(argv[1], "w+");
    fprintf(fp, "name = %s num = %d age = %d\n", "zhangsan", 1, 12);
    char name[100];
    int num;
    int age;
    rewind(fp);
    fscanf(fp, "name = %s num = %d age = %d\n", name, &num, &age);
    printf("name = %s num = %d age = %d\n",name, num, age);

    fflush(fp);
    

    return 0;
}